Skip to content

Fix for non shippable products in Product Doctor#6318

Merged
mirekm merged 4 commits intomainfrom
fix/product-doctor-non-shippable
Feb 9, 2026
Merged

Fix for non shippable products in Product Doctor#6318
mirekm merged 4 commits intomainfrom
fix/product-doctor-non-shippable

Conversation

@mirekm
Copy link
Member

@mirekm mirekm commented Feb 5, 2026

Product availability diagnostics should skip shipping zone warnings for non-shippable products (digital goods, activation codes, etc.). Products with isShippingRequired: false on their product type will no longer see false positive warnings about missing shipping zones or unreachable warehouses via shipping.

@mirekm mirekm requested a review from a team as a code owner February 5, 2026 16:21
@changeset-bot
Copy link

changeset-bot bot commented Feb 5, 2026

🦋 Changeset detected

Latest commit: 60737e4

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes false positive shipping zone warnings in the Product Doctor diagnostics for non-shippable products (digital goods, activation codes, etc.). The fix adds the isShippingRequired field from the product type to diagnostic data and conditionally skips shipping checks for products that don't require shipping.

Changes:

  • Added isShippingRequired field to GraphQL fragments and queries to fetch shipping requirement status from product types
  • Modified diagnostic logic to skip shipping zone checks for non-shippable products while maintaining warehouse/stock checks
  • Added comprehensive test coverage for both shippable and non-shippable product scenarios

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/fragments/products.ts Added isShippingRequired field to product type fragment
src/graphql/hooks.generated.ts Updated generated GraphQL hook to include new field
src/graphql/types.generated.ts Updated generated types with isShippingRequired in ProductFragment and ProductDetailsQuery
src/products/fixtures.ts Added isShippingRequired: true to fixture and removed incorrectly placed taxClass from productType
src/products/components/ProductDoctor/utils/types.ts Added isShippingRequired field to ProductDiagnosticData interface with comprehensive documentation
src/products/components/ProductDoctor/utils/mapProductToDiagnosticData.ts Maps isShippingRequired from product type with safe default to true
src/products/components/ProductDoctor/utils/mapProductToDiagnosticData.test.ts Added comprehensive tests for mapping logic including edge cases
src/products/components/ProductDoctor/utils/availabilityChecks.ts Modified to skip shipping checks for non-shippable products, includes minor performance optimization
src/products/components/ProductDoctor/utils/availabilityChecks.test.ts New comprehensive test file covering shippable/non-shippable scenarios
src/products/components/ProductDoctor/hooks/useProductAvailabilityDiagnostics.test.tsx Updated mock to include new isShippingRequired field
.changeset/long-lions-ring.md Changeset documenting the fix

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.79%. Comparing base (2417a3e) to head (60737e4).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6318      +/-   ##
==========================================
+ Coverage   42.59%   42.79%   +0.19%     
==========================================
  Files        2497     2497              
  Lines       43401    43405       +4     
  Branches     9851    10232     +381     
==========================================
+ Hits        18485    18573      +88     
+ Misses      24879    23516    -1363     
- Partials       37     1316    +1279     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mirekm mirekm changed the title Fix/product doctor non shippable Fix/product doctor for non shippable Feb 5, 2026
lkostrowski
lkostrowski previously approved these changes Feb 5, 2026
Comment on lines +6 to +37
// Mock intl for testing - validates that message placeholders are provided
const createMockIntl = (): IntlShape =>
({
formatMessage: (descriptor: MessageDescriptor, values?: Record<string, unknown>) => {
const message = String(descriptor.defaultMessage ?? "");

// Extract placeholders like {channelName} from the message
const placeholders: string[] = message.match(/\{(\w+)\}/g) ?? [];

// Verify all placeholders have corresponding values
placeholders.forEach((placeholder: string) => {
const key = placeholder.slice(1, -1); // Remove { and }

if (!values || !(key in values)) {
throw new Error(`Missing value for placeholder "${key}" in message: "${message}"`);
}
});

// Replace placeholders with values for readable test output
let result = message;

if (values) {
Object.entries(values).forEach(([key, value]) => {
result = result.replace(new RegExp(`\\{${key}\\}`, "g"), String(value));
});
}

return result;
},
}) as unknown as IntlShape;

const mockIntl = createMockIntl();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: if we need to have checks in tests for proper formatting of placeholders, maybe we should just use the actual react-intl with a mocked provider?

i'm not sure if we need this though, since we are not making any checks for messages in the actual tests below if I understand correctly. In that case we can make this much simpler:

Suggested change
// Mock intl for testing - validates that message placeholders are provided
const createMockIntl = (): IntlShape =>
({
formatMessage: (descriptor: MessageDescriptor, values?: Record<string, unknown>) => {
const message = String(descriptor.defaultMessage ?? "");
// Extract placeholders like {channelName} from the message
const placeholders: string[] = message.match(/\{(\w+)\}/g) ?? [];
// Verify all placeholders have corresponding values
placeholders.forEach((placeholder: string) => {
const key = placeholder.slice(1, -1); // Remove { and }
if (!values || !(key in values)) {
throw new Error(`Missing value for placeholder "${key}" in message: "${message}"`);
}
});
// Replace placeholders with values for readable test output
let result = message;
if (values) {
Object.entries(values).forEach(([key, value]) => {
result = result.replace(new RegExp(`\\{${key}\\}`, "g"), String(value));
});
}
return result;
},
}) as unknown as IntlShape;
const mockIntl = createMockIntl();
const mockIntl = {
formatMessage: (descriptor: MessageDescriptor) => return descriptor?.defaultMessage ?? "";
} as unknown as IntlShape;

Copilot AI review requested due to automatic review settings February 8, 2026 16:43
@mirekm mirekm changed the title Fix/product doctor for non shippable Fix for non shippable products in Product Doctor Feb 8, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

@mirekm mirekm requested a review from witoszekdev February 8, 2026 16:49
@mirekm mirekm merged commit cf1c8aa into main Feb 9, 2026
23 checks passed
@mirekm mirekm deleted the fix/product-doctor-non-shippable branch February 9, 2026 12:51
This was referenced Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants